package com.dingqb.ktdemo.expand

class ExpandD {
    val name = "ExpandD field name ==tom"
    var age: String = "this is age ";

}


fun ExpandD.getName(): String {
    return this.name;
}

fun ExpandD.getAge(): String {
    return "this";
}

fun ExpandD.exAdd(a: Int, b: Int) = a + b
val <T> List<T>.lastIndex: Int
    get() = size - 1

val <T>List<T>.last: Int
    get() = size;

fun main(args: Array<String>) {
    var expandd = ExpandD();
    println(expandd.getName());
    println(expandd.exAdd(11, 22))
    var llist = ArrayList<String>();
    llist.add("123");
    println(llist.last);

    var any=null
    println(any.toString())


}

//fun Any?.toString(): String {
//	if (this == null) return "null"
//	// 空检测之后，“this”会自动转换为非空类型，所以下面的 toString()
//	// 解析为 Any 类的成员函数
//	return toString()
//}